package com.engineering.elink.dao;

import java.util.List;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import com.engineering.elink.co.BaseCo;
import com.engineering.elink.co.CommentCo;
import com.engineering.elink.domain.Comment;
import com.engineering.elink.vo.CommentOfFileVo;
import com.engineering.elink.vo.CommentVo;

public interface CommentMapper {
    int deleteByPrimaryKey(Integer commentId);

    int insert(Comment record);

    int insertSelective(Comment record);

    Comment selectByPrimaryKey(Integer commentId);

    int updateByPrimaryKeySelective(Comment record);

    int updateByPrimaryKey(Comment record);

	List<CommentVo> selectTopCommentsByFileId(@Param("co")CommentCo co);

	int selectTopCommentsCount(@Param("co")CommentCo co);

	List<CommentVo> selectAllCommentsByTopId(@Param("bc")BaseCo bc, @Param("topId")int topId);

	int selectCount(@Param("bc")BaseCo bc, @Param("topId")int topId);

	int selectCountCommentForMe(@Param("userId")String userId);

	int selectCountMyComment(@Param("userId")String userId);

	List<CommentOfFileVo> getCommentForMe(@Param("co")BaseCo co,@Param("userId")String userId);
	
	List<CommentOfFileVo> getMyComment(@Param("co")BaseCo co,@Param("userId")String userId);
	
	@Select("select ifnull(max(comment_id),0) from comment")
	int selectMaxCommentId();
	
	@Select("select count(1) from comment where file_id =#{fileId} and user_id=#{userId}")
	int selectDistinctCount(@Param("fileId")String fileId, @Param("userId")String userId);
	
	@Select("select count(1) from comment where file_id =#{fileId} and user_id=#{userId} and top_id >0")
	int selectReplyCount(@Param("fileId")String fileId, @Param("userId")String userId);
}